package collectionTest;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author shentianyu
 * @date 2021-06-13 12:46
 *
 * set test
 */
public class SetTest {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        //遍历
        set.add("小米");
        set.add("苹果");
        set.add("华为");
        System.out.println(set.toString());

        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }

        for (String s:set
             ) {
            System.out.println(s);
        }
    }
}
